# Use C-a instead of C-b as the prefix
set -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix

# allow terminal scrolling
set-option -g terminal-overrides 'urxvt*:smcup@:rmcup@'

#set 256 colors
set -g default-terminal "screen-256color"

# set default shell
set -g default-command "exec /bin/zsh"

set -g display-time 2000

# be more responsive, changing the default delay
set -sg escape-time 1

# set scrollback
set -g history-limit 10000

# Start numbering at 1
set -g base-index 1
setw -g pane-base-index 1

# force a reload of the config file
unbind *
bind * source-file ~/.tmux.conf  \; display "Reloaded!"

# Terminal title
set-option -g set-titles on
set-option -g set-titles-string '[#S:#I] #W'
set-window-option -g automatic-rename on

# aggresive resize
setw -g aggressive-resize on

# copy mode
unbind [
bind Escape copy-mode

# Saner splitting.
bind , split-window -h
bind . split-window -v
bind S choose-session

# Pane resizing
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

##+ messages:
setw -g mode-bg magenta
setw -g mode-fg black
set -g message-bg magenta
set -g message-fg black

##+ panes:
set -g pane-border-fg black
set -g pane-border-bg default
set -g pane-active-border-fg white
set -g pane-active-border-bg default

set -g status-justify right
set -g status-bg black
set -g status-fg white
set -g status-interval 5
setw -g window-status-current-fg red
setw -g window-status-current-attr none
setw -g window-status-format '#[fg=white]#I:#W#F'
setw -g window-status-current-format '#[fg=red] #I:#W#F '

set -g status-left '#[fg=black,bold] #T'
set -g status-left-length 40
set -g status-left-fg black

set -g status-right '#[fg=black,bold] #[fg=magenta] #S:#[fg=white]#I:#P'

# Activity
setw -g monitor-activity on
set -g visual-activity on

# Mouse stuff
setw -g mouse off

# Log output to a text file on demand
bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log"

# move between panes
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
